import decimal
from fractions import Fraction

x = Fraction(2,8) # 分数
print(type(x)),print(x)
x=x+2 # 9/4
print(type(x)),print(x)
x = Fraction(2,8)
x=x-2
print(type(x)),print(x)
x = Fraction(2,8)
x=x*2
print(type(x)),print(x)
x = Fraction(2,8)
x=x/2
print(type(x)),print(x)
x=Fraction.from_float(1.25)#把浮点型转换成分数
y=float(x)#把分数转换成浮点型
y=decimal.Decimal(y)#把浮点型转换成小数型
print(type(x)),print(x),print(type(y)),print(y)
